//
//  JCClubMessageModel.m
//  SquashSpark
//
//  Created by 郭吉成 on 2017/11/23.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "JCClubMessageModel.h"
#import "NSString+Extension.h"

@implementation JCClubMessageModel

+ (JCClubMessageModel *)creatModelWithData:(NSDictionary *)dataDic{
    JCClubMessageModel *model = [JCClubMessageModel new];
    model.messageID = [NSString checkIfNullWithString:dataDic[@"ID"]];
    model.userName = [NSString checkIfNullWithString:dataDic[@"UserName"]];
    model.icon = [NSURL URLWithString:[NSString checkIfNullWithString:dataDic[@"Icon"]]];
    model.content = [NSString checkIfNullWithString:dataDic[@"Content"]];
    model.creatTime = [NSString checkIfNullWithString:dataDic[@"CreateTime"]];
    return model;
}

+ (NSArray <JCClubMessageModel *>*) creatFindClubList:(NSArray *)sourceArray{
    if ([sourceArray isEqual:[NSNull null]] || sourceArray == nil) {
        return nil;
    }
    NSMutableArray *models = [NSMutableArray array];
    for (NSDictionary *dic in sourceArray) {
        JCClubMessageModel *model = [self creatModelWithData:dic];
        [models addObject:model];
    }
    return [models mutableCopy];
}

@end
